package com.winchain.provider.expiration.rx;

import com.shell.framework.command.ChainBase;
import com.shell.framework.command.CommandContext;
import com.winchain.provider.expiration.cmd.BillExpChdSettlCmd;
import com.winchain.provider.expiration.cmd.BillExpDlySettlCmd;
import com.winchain.provider.expiration.cmd.BillExpSndSettlCmd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillExpSettlSubscriber extends TransactionNewSubscriber<BillExpirationEvent> {
	@Autowired
	private BillExpChdSettlCmd billExpChdSettlCmd;
	@Autowired
	private BillExpSndSettlCmd billExpSndSettlCmd;
	@Autowired
	private BillExpDlySettlCmd billExpDlySettlCmd;

	public void execute(BillExpirationEvent t) {
		CommandContext<BillExpirationEvent> context = new CommandContext();
		context.setSource(t);

		ChainBase<BillExpirationEvent> crb = new ChainBase();
		boolean pm = t.isPm();
		if (!pm) {
			crb.add(this.billExpChdSettlCmd);
		}
		crb.add(this.billExpSndSettlCmd);

		crb.add(this.billExpDlySettlCmd);

		crb.execute(context);
	}
}
